package Util;

import java.io.IOException;

public class BasicPatterns 
{
	private static final char [] letters_ = { 
		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
        '_' };
	
	private static final char [] numbers = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
	
	/**
	 * Verifies if a character is a white space.
	 * @param c the character to be verified.
	 * @return
	 * True if it is the white space character.
	 * False if it is not the white space character.
	 */
	public static boolean isWhiteSpace (char c) 
	{ 
		return (c == ' ') || (c == '\t'); 
	}
	
	/**
	 * Verifies if a character represents a line feed.
	 * @param c the character to be verified.
	 * @return
	 * True if it is the line feed character.
	 * False if it is not the line feed character.
	 * @throws IOException 
	 */
	public static boolean isLineFeed (char c) throws IOException
	{ 
		return (c == '\n');
	}	
	
	/**
	 * Verifies if a character represents the beginning of a comment line.
	 * @param c the character to be verified.
	 * @return
	 * True if it is the comment beginning character.
	 * False if it is not the comment beginning character.
	 */
	public static boolean isComment (char c) 
	{ 
		return (c == '#'); 
	}
	
	/**
	 * Verifies if a character is a letter or an underscore.
	 * @param c the character to be verified.
	 * @return
	 * True if it is a letter or an underscore.
	 * False it it is not a letter or an underscore.
	 */
	public static boolean isLetter_(char c)
	{
		for (int i = 0; i < letters_.length; i++)
		{
			if (c == letters_[i])
				return true;
		}
		return false;
	}
	
	/**
	 * Verifies if a character is a number
	 * @param c the character to be verified.
	 * @return
	 * True if it is a number.
	 * False if it is not a number.
	 */
	public static boolean isNumber(char c)
	{
		for (int i = 0; i < numbers.length; i++)
		{
			if (c == numbers[i])
				return true;
		}
		return false;
	}
}
